package com.FindMyStuff.Model;

public enum ItemCategory {
Heirloom("h"), Keepsake("k"), Other("o"), All("a");
	
	/**
	 * Holds the Enum Value
	 */
	private String value;
	
	/**
	 * Private Constructor to store the enum value
	 * @param string
	 */
	private ItemCategory(String string)
	{
		value = string;
	}
	
	/**
	 * Creates a String of the enum 
	 */
	public String toString() {
		String res = "";
	       switch (this) {
	         case Heirloom:
	        	 res = value;
	        	 break;
	         case Keepsake:
	        	 res = value;
	        	 break;
	         case Other:
	        	 res = value;
	        	 break;
	         case All:
	        	 res = value;
	        	 break;
	        }
		return res;
	 }
	
	/**
	 * Converts string into an enum 
	 * @param string value to convert
	 * @return converted enum
	 */
	public static ItemCategory convertToCategory(String string)
	{
		if(string.equals("h"))
		{
			return Heirloom;
		}
		else if(string.equals("k"))
		{
			return Keepsake;
		} else if(string.equals("o"))
		{
			return Other;
		} else 
		{
			return All;
		}
		
	}

	/**
	 * Converts string into an enum 
	 * @param string that directly correlates to an enum
	 * @return converted enum
	 */
	public static ItemCategory convertStringtoCategory(String string) {
		if(string.equals("Heirloom"))
		{
			return Heirloom;
		}
		else if(string.equals("Keepsake"))
		{
			return Keepsake;
		} 
		else if(string.equals("Other"))
		{
			return Other;
		} else 
		{
			return All;
		}
	}
	
	/**
	 * Checks if the given category is the same as this category
	 * @param cat to check
	 * @return true if they match
	 */
	public boolean equals(ItemCategory cat)
	{
		if(this.toString().equals(cat.toString()))
		{
			return true;
		}
		return false;
	}
	
	
	
}
